import axios from 'axios'
import config from '../config'
// /api/files-upload
// /api/files
export function create (entity) {
  return axios.post(config.SERVER_URL + window.apiPath + '/files', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}
export function upload (entity) {
  return axios.post(config.SERVER_URL + window.apiPath + '/files-upload', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}
export function edit (entity) {
  return axios.put(config.SERVER_URL + window.apiPath + '/files', {...entity, responseType: 'json'})
    .then(resp => resp.data)
}
export function deleteById (id) {
  return axios.delete(config.SERVER_URL + window.apiPath + '/files/' + id, {responseType: 'json'})
    .then(resp => resp.data)
}
export function searchById (id) {
  return axios.get(config.SERVER_URL + window.apiPath + '/files/' + id, {responseType: 'json'})
    .then(resp => resp.data)
}
export function search () {
  return axios.get(config.SERVER_URL + window.apiPath + `/files`, {responseType: 'json'})
    .then(resp => resp)
}
export function searchAll (query = '') { // page=${page}&size=${config.PAGE_SIZE}&
  return axios.get(config.SERVER_URL + window.apiPath + `/files?query=${query}`, {responseType: 'json'})
  // return axios.get(config.SERVER_URL + window.apiPath + `/duty-descriptions`, {params: params}, {responseType: 'json'})
    .then(resp => resp)
}

